package com.j.lemon.learn.jdbc;

import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author lijunjun
 * @Date 2020/9/4 20:04
 * @Description
 */
public class JDBCTest {
    public static void main(String[] args) throws Exception {
        DataSource dataSource = DBUtils.getDataSource();

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

//        List<String> list = new ArrayList<>();
//        for (int i = 0; i < 1000; i++) {
//            list.add("INSERT INTO junjun.uap_host_acct (HOST_ACCT_ID, HOST_ID, PWD_RULE_ID, ACCT_NAME, ACCT_PWD, ACCT_UID, ACCT_USER_SHELL,\n" +
//                    "                                  ACCT_USER_HOME, ACCT_STATUS, LOCK_DESC, LOCK_MAIN_ACCT_ID, LOCK_TIME,\n" +
//                    "                                  LOCK_EFFECT_TIME, LOCK_EXPIRE_TIME, DESCRIPTION, PWD_UPDATE_TIME, SYNC_STATUS,\n" +
//                    "                                  SYNC_DESC, FTP_ENABLED, IS_DELETE, IS_PUBLIC, ACCT_TYPE, CREATE_TIME,\n" +
//                    "                                  LAST_UPDATE_TIME, WORK_NO, IS_SSO, LOGINIP, IS_SENSITIVE)\n" +
//                    "VALUES ("+i+", 129315, 10021, '6', '16|33|75|102|-96|49|32|7|99|-11|-120|-8|58|81|-106|-57|-125', '1040',\n" +
//                    "        '/bin/bash', '/home/liuxl', '1', null, null, null, null, null, null, '2019-11-12 18:36:57', '1', null, null,\n" +
//                    "        '1', '0', '01', '2019-11-12 18:36:57', '2019-11-12 18:36:57', null, null, null, null)");
//        }
//        String[] objects = list.toArray(new String[0]);
//        System.out.println("start batch size:"+objects.length);
//        long s = System.currentTimeMillis();
//        jdbcTemplate.batchUpdate(objects);
//        long e = System.currentTimeMillis();
//        System.out.println("end batch");
//        long t = e - s;
//        System.out.println("cost:"+t);
//        Map<String, Object> showCreateTableIapAuditType = jdbcTemplate.queryForMap("show create table iap_account");
        String showCreateTableIapAuditType = jdbcTemplate.queryForObject("select dbms_metadata.get_ddl('TABLE','ACCESS_POLICY') from dual",String.class);
        System.out.println(showCreateTableIapAuditType);


    }
}
